#ifndef DISK_MANAGER_H
#define DISK_MANAGER_H

#include "storage/page.h"
#include <string>
#include <fstream>
#include <unordered_map>

class DiskManager {
public:
    DiskManager(const std::string& dbFile);
    ~DiskManager();

    void readPage(uint32_t pageId, char* data);
    void writePage(uint32_t pageId, const char* data);

    uint32_t allocatePage();
    void deallocatePage(uint32_t pageId);

private:
    std::string dbFile;
    std::fstream file;
    std::unordered_map<uint32_t, bool> pageAllocationMap;

    void ensureFileSize(uint32_t pageId);
};

#endif // DISK_MANAGER_H